#!/bin/bash

: ${1?"You must provide username for what wish change password: `basename $0` username"}

echo "Please enter new password for user $1 (will not be echoed):"
echo "If you can't fabricate that, you may  use one from autogenerated:"
#http://www.google.ru/url?sa=t&ct=res&cd=1&url=http%3A%2F%2Fwww.osix.net%2Fmodules%2Farticle%2F%3Fid%3D570&ei=2WBPR9f6OY76wQGm8r2_Bw&usg=AFQjCNFtjmHwcfia-azJvbGMyOXX5UDV8Q&sig2=uWKnYIFTv9o8eO-d3b3Ofg
genpass
stty -echo #Do not echo anything!
read Passwd
stty echo #Return
echo "$Passwd" | passwd --stdin "$1"

{
echo
date
echo "$Passwd"
    [ ! -d "/root/USERS/" ] && mkdir "/root/USERS/"
} >> "/root/USERS/$1"

echo 'All tokens updated!'